import request from '@/hooks/utils/http'
import { AxiosPromise } from 'axios'

export class DictService {
    // 查询字典类型列表
    static listType(query: DictTypeQuery): AxiosPromise<DictTypeVO[]> {
        return request({
            url: '/system/dict/type/list',
            method: 'get',
            params: query
        });
    }

// 查询字典类型详细
    static getType(dictId: number | string): AxiosPromise<DictTypeVO> {
        return request({
            url: '/system/dict/type/' + dictId,
            method: 'get'
        });
    }

// 新增字典类型
    static addType(data: DictTypeForm) {
        return request({
            url: '/system/dict/type',
            method: 'post',
            data: data
        });
    }

// 修改字典类型
    static updateType(data: DictTypeForm) {
        return request({
            url: '/system/dict/type',
            method: 'put',
            data: data
        });
    }

// 删除字典类型
    static delType(dictId: string | number | Array<string | number>) {
        return request({
            url: '/system/dict/type/' + dictId,
            method: 'delete'
        });
    }

// 刷新字典缓存
    static refreshCache() {
        return request({
            url: '/system/dict/type/refreshCache',
            method: 'delete'
        });
    }

// 获取字典选择框列表
    static optionselect(): AxiosPromise<DictTypeVO[]> {
        return request({
            url: '/system/dict/type/optionselect',
            method: 'get'
        });
    }
// 根据字典类型查询字典数据信息
    static getDicts(dictType: string): AxiosPromise<DictDataVO[]> {
        return request({
            url: '/system/dict/data/type/' + dictType,
            method: 'get'
        });
    }

// 查询字典数据列表
    static listData(query: DictDataQuery): AxiosPromise<DictDataVO[]> {
        return request({
            url: '/system/dict/data/list',
            method: 'get',
            params: query
        });
    }

// 查询字典数据详细
    static getData(dictCode: string | number): AxiosPromise<DictDataVO> {
        return request({
            url: '/system/dict/data/' + dictCode,
            method: 'get'
        });
    }

// 新增字典数据
    static addData(data: DictDataForm) {
        return request({
            url: '/system/dict/data',
            method: 'post',
            data: data
        });
    }

// 修改字典数据
    static updateData(data: DictDataForm) {
        return request({
            url: '/system/dict/data',
            method: 'put',
            data: data
        });
    }

// 删除字典数据
    static delData(dictCode: string | number | Array<string | number>) {
        return request({
            url: '/system/dict/data/' + dictCode,
            method: 'delete'
        });
    }

}

export interface DictTypeVO extends BaseEntity {
    dictId: number | string;
    dictName: string;
    dictType: string;
    remark: string;
}

export interface DictTypeForm {
    dictId: number | string | undefined;
    dictName: string;
    dictType: string;
    remark: string;
}

export interface DictTypeQuery extends PageQuery {
    dictName: string;
    dictType: string;
}

export interface DictDataQuery extends PageQuery {
    dictName: string;
    dictType: string;
    dictLabel: string;
}

export interface DictDataVO extends BaseEntity {
    dictCode: string;
    dictLabel: string;
    dictValue: string;
    cssClass: string;
    listClass: ElTagType;
    dictSort: number;
    remark: string;
}

export interface DictDataForm {
    dictType?: string;
    dictCode: string | undefined;
    dictLabel: string;
    dictValue: string;
    cssClass: string;
    listClass: ElTagType;
    dictSort: number;
    remark: string;
}

